Function Reference

FileMove

Moves one or more files

FileMove ( "source", "dest" [, flag] )

 

Parameters

source The source path and filename of the file to move. (* wildcards are supported)
dest The destination path and filename of the moved file. (* wildcards are supported)
flag [optional] this flag determines whether to overwrite files if they already exist:
Can be a combination of the following:
 0 = (default) do not overwrite existing files
 1 = overwrite existing files
 8 = Create destination directory structure if it doesn't exist (See Remarks).

 

Return Value

Success: Returns 1.
Failure: Returns 0 if source cannot be moved or if dest already exists and flag=0.

 

Remarks

If the source and destination paths are on different volumes a copy and delete operation is performed rather than a move.

Because AutoIt lacks a "FileRename" function, use FileMove to rename a file!

The destination directory must already exist, except using with flag value '8'.
For instance the combined flag '9' (1 + 8) overwrites the target file and prechecks for the destination directory structure and if it doesn't exist creates it automatically.

 

Related

FileCopy, FileDelete, FileRecycle, DirMove

 

Example


FileMove("C:\foo.au3", "D:\mydir\bak.au3")

; Second example:
;   uses flags '1' (owerwriting) and '8' (autocreating target dir structure) together
;   moves all txt-files from temp to txtfiles and prechecks if
;   target directory structure exists, if not then automatically creates it
FileMove(@TempDir & "\*.txt", @TempDir & "\TxtFiles\", 9)